﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class page_GoodLoss_Manager : PageBase
{
    private static DataTable dt = new DataTable();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Utility.InitUltraWebGrid.InitDisplayLayOut(this.uwgMain);
            this.uwgMain.Height = 350;

            this.BindDDLGoods();
            this.BindData();
        }
    }

    #region Web 窗体设计器生成的代码

    protected override void OnLoad(EventArgs e)
    {
        isRequestLogin = true;                                  //是否需要登录
        RequestLoginPage = this.Request.Url.AbsoluteUri;        //获取决对Url
        isAtFramePageLogin = true;                              //是框架页

        //RequestCompetences = Competences.BuildCompetencesList(Competences.shs);//页面权限

        base.OnLoad(e);
    }

    #endregion

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        this.BindData();
    }

    protected void btnExcel_Click(object sender, EventArgs e)
    {
        Utility.DataTableToExcel.DataTableToExcelAndDownload(dt, "GoodsLossRate.xls");
    }

    protected void btnSetGoodLoss_Click(object sender, EventArgs e)
    {
        Response.Redirect("GoodLoss_Set.aspx?GoodID="+hGoodID.Value);
    }

    #region

    private void BindDDLGoods()
    {
        dt = new DAL.Tables.tbl_Shop_Good().Open("","","");

        this.ddlGoods.DataSource = dt;
        this.ddlGoods.DataTextField = "GoodName_CN";
        this.ddlGoods.DataValueField = "ID";

        this.DataBind();

        this.ddlGoods.Items.Insert(0, new ListItem("--选择产品--", "0"));
    }

    private void BindData()
    {
        string sCondtion = "1=1";

        if (ddlGoods.SelectedValue != "0")
        {
            sCondtion += " and ID=" + ddlGoods.SelectedValue;
        }
        if (txtGoodNO.Text != "")
        {
            sCondtion += " and GoodNO like'%" + Shove._Web.Utility.FilteSqlInfusion(txtGoodNO.Text) + "%'";
        }

        dt = new DAL.Views.V_Shop_Good().Open("", sCondtion, "");

        this.uwgMain.DataSource = dt;
        this.uwgMain.DataBind();
    }

    #endregion
}
